# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=nose
pkgbase="python-${_realname}"
pkgname=("python3-${_realname}" "python2-${_realname}")
pkgver=1.3.7
pkgrel=3
pkgdesc="A discovery-based unittest extension"
arch=('i686' 'x86_64')
license=('LGPL-2.1')
url="https://nose.readthedocs.io/"
makedepends=("python2-setuptools" "python3-setuptools")
source=("https://pypi.python.org/packages/source/n/nose/nose-${pkgver}.tar.gz")
sha256sums=('f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98')

prepare() {
  cd "$srcdir/nose-$pkgver"
  sed -i -e "s:man/man1:share/man/man1:g" setup.py
}

build() {
  cd "${srcdir}/nose-${pkgver}"
  sed -i -e "s:man/man1:share/man/man1:g" setup.py

  cd "$srcdir"
  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r nose-${pkgver} ${builddir}
    pushd ${builddir}
    /usr/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-nose() {
  depends=("python3-setuptools")

  cd "${srcdir}/python3-build"
  /usr/bin/python3 setup.py install --prefix=/usr --root="${pkgdir}" -O1

  rm -f ${pkgdir}/usr/bin/nosetests
  rm -rf "${pkgdir}/usr/share"
}

package_python2-nose() {
  depends=("python2-setuptools")

  cd "${srcdir}/python2-build"
  /usr/bin/python2 setup.py install --prefix=/usr --root="${pkgdir}" -O1
}
